package jp.co.technotree.apl.cmd.top;
import jp.co.technotree.apl.api.common.AisinSession;
import jp.co.technotree.apl.api.common.AisinTransaction;
import jp.co.technotree.apl.cmd.login.LoginContext;
import jp.co.technotree.apl.cmd.login.LoginManager;
import jp.co.technotree.common.ctrl.ErrorMap;
import jp.co.technotree.common.ctrl.FormBean;
import jp.co.technotree.common.ctrl.command.ActionCommand;
import jp.co.technotree.common.ctrl.context.RequestContext;
import jp.co.technotree.common.ctrl.context.ResponseContext;
import jp.co.technotree.common.ctrl.forward.ForwardMessage;
import jp.co.technotree.common.ctrl.forward.ForwardMessageManager;
import jp.co.technotree.common.exception.CommandExecuteException;
import jp.co.technotree.common.exception.ValidateException;
import jp.co.technotree.common.util.DBGLog;


public class Top3000View extends ActionCommand{
	private static String CLASSNAME=Top3000View.class.getSimpleName();

	@Override
	public ForwardMessage doExecute(RequestContext requestContext,
			ResponseContext responseContext, FormBean formBean,
			ForwardMessageManager forwardManager)
			throws CommandExecuteException {
		String METHODNAME = "doExecute";
		DBGLog.log(CLASSNAME,METHODNAME,"START");

		Top1000Bean inBean = (Top1000Bean)formBean;
		Top1000Bean outBean = inBean;
		if ( outBean == null ) outBean = new Top1000Bean();
		
		try{
//			LoginContext loginCtx = LoginManager.getLoginContext(requestContext);
//			XCGSession session = XCGTransaction.login(loginCtx.getCompanyCd(), loginCtx.getUserCd(), loginCtx.getPassword());
//			
//			session.close();
		}catch(Exception ex){
			ex.printStackTrace();
		}
		ForwardMessage forward = forwardManager.getJspForwardMessage("top3000", outBean);
		if("mst0001".equals(inBean.getNextPage())){
			outBean.setNextPage(null);
			forward = forwardManager.getRedirectForwardMessage("/app/master/mst0001", outBean);
		}else if("bak1000".equals(inBean.getNextPage())){
			outBean.setNextPage(null);
			forward = forwardManager.getRedirectForwardMessage("/app/backup/bak1000", outBean);
		}
		
		

		DBGLog.log(CLASSNAME,METHODNAME,"END");
		return forward;
		
		
	}


	@Override
	public ForwardMessage doValidate(RequestContext requestContext,
			ResponseContext responseContext, FormBean formBean,
			ErrorMap errorMap, ForwardMessageManager forwardManager)
			throws ValidateException {
		String METHODNAME = "doValidate";
		DBGLog.log(CLASSNAME,METHODNAME,"START");
		ForwardMessage forward = null;
		
		DBGLog.log(CLASSNAME,METHODNAME,"END");
		return forward;
	}

}
